<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="UTF-8"%>
<jsp:useBean id="user" class="eai.tp2.lpco.web.beans.UserBean" scope="session" />
<jsp:useBean id="results" class="eai.tp2.lpco.web.beans.ResultsBean" scope="session" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt" lang="pt">
<head>
<title>Low-Price Cameras Online</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="javascript" src="javascript/sub-menus.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="style/style.css"  />
</head>
<body> 
<table width="845" border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
     <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td colspan="5" ><div class="margem-direita"><img src="imagens/top.gif" width="850" height="108" alt="" /></div></td> 
  </tr> 
  <tr> 
    <td colspan="5" ></td> 
  </tr> 
  <tr> 
    <td colspan="5"></td> 
  </tr> 
  <tr> 
    <td width="10" rowspan="9">&nbsp;</td> 
    <td colspan="3"></td> 
    <td width="40" rowspan="9">&nbsp;</td> 
  </tr> 
  <tr> 
    <td>&nbsp;</td> 
    <td colspan="2" valign="top"></td> 
  </tr> 
  <tr> 
    <td width="188"><div class="menu"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
        <tr>
          <td width="76%"> </td>
          <td width="24%"> </td>
        </tr>
        <%
        	if (user.isLogged()) {
        		out
        				.print("<tr>"
        						+ "<td> "
        						+ "<div class=\"normal-text\">"
        						+ user.getUsername()
        						+ "</div></td>"
        						+ "<td align=\"right\"><form action=\"Logout\" method=\"post\"><input class=\"botao-login\" name=\"bLogout\" type=\"submit\" value=\"Logout\" /></form></td>"
        						+ "</tr>");
        	} else {
        		out
        				.print("<form name=\"login-form\" method=\"post\"  id=\"login-form\" action=\"Authentication\">"
        						+ "<tr>"
        						+ "<td><div class=\"normal-text\">Username:</div></td>"
        						+ "<td align=\"right\"><input  name=\"username\" type=\"text\" class=\"textfield-login\" size=\"15\"/></td>"
        						+ "</tr>"
        						+ "<tr>"
        						+ "<td><div class=\"normal-text\">Password:</div></td>"
        						+ "<td align=\"right\"><input  name=\"password\" type=\"password\" class=\"textfield-login\" size=\"15\"/></td>"
        						+ "</tr>"
        						+ "<tr>"
        						+ "<td> </td>"
        						+ "<td align=\"right\"><input type=\"submit\" name=\"Submit\" value=\"Login\" class=\"botao-login\"/></td>"
        						+ "</tr>"
        						+ "<tr>"
        						+ "<td colspan=\"2\"><a href=\"register.html\" class=\"text-link\"> register </a></td>"
        						+ "</tr>" + "</form>");
        	}
        %>
        <tr>
          <td colspan="2" style="border-bottom:1px solid #999999; "> </td>
        </tr>
        <tr>
          <td colspan="2" style="border-bottom:1px solid #999999; "><a href="javascript:submenu('sub-menu-1')" class="menu-item"><img src="imagens/down.png" width="5" height="5" id="sub-menu-1-img" class="img" alt=""/>&nbsp;Orders</a><a href="cart.jsp" style="display:none;" id="sub-menu-1" class="menu-item">&nbsp;Cart</a><a href="DatabaseOrder?do=historic" style="display:none;" id="sub-menu-1-1" class="menu-item">&nbsp;Historic</a></td>
          </tr>
        <tr> 
          <td colspan="2" style="border-bottom:1px solid #999999; "><a href="index.jsp" class="menu-item">&nbsp;List</a></td> 
          </tr> 
        <tr> 
          <td colspan="2" style="border-bottom:1px solid #999999; "><h2>&nbsp;Search</h2></td> 
          </tr> 

        <tr>
          <td colspan="2" style="border-bottom:1px solid #999999; "><a href="DatabaseUser?do=personal" class="menu-item">&nbsp;Personal Info</a></td>
        </tr>
        <tr>
          <td colspan="2"/>
        </tr>
        <tr>
          <td colspan="2"> </td>
        </tr>
        <tr> 
          <td colspan="2"/> 
          </tr> 
      </table>
    </div></td> 
        <td style="width: 50px;">&nbsp;</td>
    <td colspan="2" valign="top"><div class="normal-text-hline"><a href="javascript: history.go(-1)" class="text-link">&nbsp;back&nbsp;</a></div><table width="100%" border="0" cellspacing="3" cellpadding="0"> 
            <tr > 
              <td width="50%" class="normal-text-hline"><form name="search-form" method="post"  id="search-form" action="ExternalCatalog">&nbsp;Search&nbsp;<input  name="search" type="text" class="textfield-login" size="15"/>&nbsp;<input type="submit" name="Submit" value="Search" class="botao-login"/></form></td>                
            </tr>     
             <tr > 
              <td width="50%" bgcolor="#666666" style="width: 500px"><h2>&nbsp;Results<% if(results.getQuery()!=null) out.print(" for '"+results.getQuery()+"'"); %></h2></td> 
              <td width="50%" align="left" ></td> 
            </tr>             
              <%
                           	if (results.haveResults()) {
                           		if (results.getResults().size() > 0) {
                           			for (String name : results.getResults()) {
                           				out
                           						.print("<form name=\"results-form\" method=\"post\"  id=\"results-form\" action=\"DatabaseCatalog\"><table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\"><tr>"
                           								+ "<td bgcolor=\"#CCCCCC\" style=\"width: 500px\"><a href=\"ExternalCatalog?do=detail&name="
                           								+ name
                           								+ "\" class=\"text-link\">&nbsp;"
                           								+ name
                           								+ "&nbsp;</a></td>"
                           								+ "<td align=\"left\" bgcolor=\"#CCCCCC\" >&nbsp;<input type=\"checkbox\" id=\"camera_ckbox\" name=\"camera_ckbox\" value=\""
                           								+ name + "\" /></td>" + "</tr>");
                           			}
                           			out
                           					.print("<tr>"
                           							+ "<td >&nbsp;</td>"
                           							+ "<td align=\"left\" >&nbsp;<input class=\"botao-login\" name=\"add\" type=\"submit\" value=\"Add to Database\"/></td>"
                           							+ "</tr>");
                           		} else
                           			out
                           					.print("<tr>"
                           							+ "<td bgcolor=\"#CCCCCC\"><h2>&nbsp;The search returned 0 results</h2></td>"
                           							+ "<td align=\"left\" bgcolor=\"#CCCCCC\" >&nbsp;</td>"
                           							+ "</tr>");
                           	} else
                           		out
                           				.print("<tr>"
                           						+ "<td bgcolor=\"#CCCCCC\"><h2>&nbsp;There are no results</h2></td>"
                           						+ "<td align=\"left\" bgcolor=\"#CCCCCC\" >&nbsp;</td>"
                           						+ "</tr></form>");
                           %>                                   
            <tr>
              <td align="right"></td>
              <td align="right"></td>
            </tr>
            <tr> 
              <td colspan="2"></td> 
            </tr> 
    </table></td> 
  </tr> 
  <tr>
    <td>&nbsp;</td>
    <td rowspan="6" valign="top">&nbsp;</td>
    <td valign="top"></td>
  </tr>
  <tr> 
    <td rowspan="3"></td> 
    <td valign="top">     
    </td>
  </tr>
  <tr>
    <td valign="top"></td>
  </tr>
  <tr>
    <td valign="top"></td>
  </tr> 
  <tr> 
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr> 
  <tr> 
    <td valign="top"></td> 
     <td valign="top"></td>
  </tr> 
  <tr> 
    <td colspan="5"></td> 
  </tr> 
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td rowspan="3">&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr> 
    <td colspan="5"><div class="margem-baixo">&nbsp;</div></td> 
  </tr> 
  <tr> 
    <td width="10">&nbsp;</td> 
    <td></td> 
    <td width="40">&nbsp;</td> 
    <td width="574">&nbsp;</td> 
    <td width="40">&nbsp;</td> 
  </tr> 
</table> 
</body>
</html>
